# -*- coding:utf-8 -*-
# 队列的使用
import threading
from queue import Queue
import time

queue = Queue(maxsize=5)


def put_data():
    for i in range(1, 10):
        queue.put(i)
        print(f"{i}添加完成")
        time.sleep(1)


def get_data():
    for i in range(1, 10):
        num = queue.get()
        print(f"{num}获取成功")
        queue.task_done()
        time.sleep(1)


if __name__ == '__main__':
    t1 = threading.Thread(target=put_data)
    t2 = threading.Thread(target=get_data)
    t1.start()
    t2.start()
    queue.join()
